Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deactivate customer #557

Merged
merged 11 commits into from
Jan 6, 2025
Merged

Deactivate customer #557

merged 11 commits into from
Jan 6, 2025

Conversation

MariaBonde
Copy link
Contributor

@MariaBonde MariaBonde commented Jan 3, 2025

Added the possibility of deactivating (and activating) customers, with a toggle to filter out the deactivated customers.
Skjermbilde 2025-01-03 kl  13 54 41

@MariaBonde MariaBonde merged commit 3443fb5 into main Jan 6, 2025
3 checks passed
@MariaBonde MariaBonde deleted the deactivateCustomer branch January 6, 2025 08:34
Copy link

@astride astride left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! I might have challenged some frontend-specific conventions in my comments in the frontend project, please let me know if I have so that I can learn. :)

One last note: I would suggest to generally use maximum one empty line between code lines/blocks.

@@ -47,7 +49,7 @@ public async Task<ActionResult<List<EngagementPerCustomerReadModel>>> Get(
var selectedOrgId = await organisationRepository.GetOrganizationByUrlKey(orgUrlKey, ct);
if (selectedOrgId is null) return BadRequest();

var absenceReadModels = new EngagementPerCustomerReadModel(-1, AbsenceCustomerName,
var absenceReadModels = new EngagementPerCustomerReadModel(-1, AbsenceCustomerName, true,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var absenceReadModels = new EngagementPerCustomerReadModel(-1, AbsenceCustomerName, true,
var absenceReadModels = new EngagementPerCustomerReadModel(-1, AbsenceCustomerName, IsActive: true,

Consider defining what is true

@@ -301,7 +318,7 @@ private CustomersWithProjectsReadModel HandleGetAbsenceWithAbsences(string orgUr
{
var vacation = new EngagementReadModel(-1, "Ferie", EngagementState.Absence, false);

var readModel = new CustomersWithProjectsReadModel(-1, AbsenceCustomerName + " og Ferie",
var readModel = new CustomersWithProjectsReadModel(-1, AbsenceCustomerName + " og Ferie", true,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var readModel = new CustomersWithProjectsReadModel(-1, AbsenceCustomerName + " og Ferie", true,
var readModel = new CustomersWithProjectsReadModel(-1, AbsenceCustomerName + " og Ferie", IsActive: true,

Consider defining what is true

table: "Customer",
type: "bit",
nullable: false,
defaultValue: true);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will this default true value be added to existing Customer objects in the database? Does the AddColumn-method call handle this?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively: You could replace the property IsActive with property IsDeactivated (the defaultValue would then implicitly be false). Then the existing consumer objects don't need to be handled.


function toggleListElementVisibility() {
setIsListElementVisible((old) => !old);
}

async function onActivate(customerId: number, active: boolean) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming the active variable to a name indicating whether it represents the current state or the target state. active may be interpreted either way.

async function onActivate(customerId: number, active: boolean) {
if (isLoading) return;
setIsLoading(true);
setIsActive(active);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be set here, or after a successful fetch?

<>
<div className="sidebar z-10 bg-background_grey h-full flex flex-col gap-6 p-4 w-[300px] overflow-y-auto">
<div className="flex flex-row justify-between items-center">
<h1 className="">Filter</h1>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is className needed here?


async function onActivate(customerId: number, active: boolean) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments regarding the active variable here as in CustomerRow.tsx

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, perhaps: Could/Should this (de)activation button/logic be a separate component that is used both places?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants